home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CDICTION / TAOUTILS.C < prev    next >
Text File  |  1989-09-15  |  3KB  |  93 lines

  1.  
  2. #include "TaoUtils.h"
  3. #include "CBartender.h"
  4. #include "CError.h"
  5. #include "TBUtilities.h"
  6. #include "ColorToolbox.h"
  7.  
  8. #define kPreferredFontStr    1002    /* 'STR ' ID for preferred font family */
  9.  
  10. extern CBartender    *gBartender;
  11. extern CError        *gError;
  12. /*****************************************************************************/
  13. void SetCmdEnable( Int32 cmd,Int16 flag)
  14. {
  15.     if (flag)
  16.         gBartender->EnableCmd( cmd);
  17.     else gBartender->DisableCmd( cmd);
  18.  
  19. }    /* SetCmdEnable */
  20. /*****************************************************************************/
  21. void GetPreferredFontName( StringPtr fontName)
  22. {
  23.     StringHandle    s;
  24.     
  25.     s = GetString( kPreferredFontStr);
  26.     if (s)
  27.     {
  28.         CopyPString( *s, fontName);
  29.         HPurge( s);
  30.     }
  31.     else GetFontName(1, fontName);
  32.  
  33. }    /* GetPreferredFontName */
  34. /*****************************************************************************/
  35. Int16 GetPreferredFontNum( void)
  36. {
  37.     Int16 num;
  38.     Str255    name;
  39.     
  40.     GetPreferredFontName( name);
  41.     GetFontNumber( name, &num);
  42.     return num;
  43.  
  44. }    /* GetPreferredFontNum */
  45. /*****************************************************************************/
  46. void    myDrawSICN( Int16 SICNid, Int16 index, Point location, Int16 mode)
  47. {
  48.     Handle        theSICN;
  49.     BitMap        theImage;
  50.     Rect        theBounds;
  51.     
  52.     theSICN = GetResource('SICN', SICNid);
  53.     CheckResource(theSICN);
  54.     
  55.     HLock(theSICN);
  56.                                         /* A SICN resource is really a list    */
  57.                                         /*   of small icons, each of which    */
  58.                                         /*   has 32 bytes of data            */
  59.                                         /*   16 x 16 = 256 bits = 32 bytes    */
  60.                                         
  61.                                         /* Create a bitmap so we can copy    */
  62.                                         /*   the SICN image on the screen    */
  63.                                         
  64.                                         /* Index into handle to get a ptr    */
  65.                                         /*   to the SICN bit image            */
  66.     theImage.baseAddr = *theSICN + (index - 1) * 32;
  67.     theImage.rowBytes = 2;                /* 16 bits is 2 bytes                */
  68.     
  69.                                         /* Place bitmap at desired locaton    */
  70.     SetRect(&theBounds, location.h, location.v,
  71.                         location.h + 16, location.v + 16);
  72.     theImage.bounds = theBounds;
  73.     
  74.                                         /* Copy image on to the screen        */
  75.     CopyBits(&theImage, &thePort->portBits,
  76.              &theBounds, &theBounds, mode, NIL);
  77.              
  78.     HUnlock(theSICN);
  79. }
  80. /*****************************************************************************/
  81. Boolean IsDeepPort( void)
  82. /*
  83.     return true if thePort has bit depth > 1
  84. */
  85. {
  86.     if (((CGrafPtr)thePort)->portVersion < 0)    /* is it a color grafport? */
  87.         return ((**((CGrafPtr)thePort)->portPixMap).pixelSize > 1);
  88.     else
  89.         return FALSE;
  90.         
  91. }    /* IsDeepPort */
  92. /*****************************************************************************/
  93.